package com.baizhi.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * 测试jsp模板集成
 */
@Controller
public class JspController {

    @RequestMapping("index")
    public String index() {
        System.out.println("index ok");
        return "index";
    }

    @RequestMapping("showInfo")
    public String showAll(HttpServletRequest request) {
        Map<String, Object> userInfo = new HashMap<>();
        userInfo.put("name", "小陈");
        userInfo.put("age", 23);
        userInfo.put("salary", 1024.68);
        userInfo.put("birthday", new Date());
        request.setAttribute("user", userInfo);
        return "showInfo";
    }
}
